#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/ide.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/gpio.h>
#include <linux/cdev.h>
#include <linux/device.h>
#include <linux/of_gpio.h>
#include <linux/semaphore.h>
#include <linux/timer.h>
#include <linux/irq.h>
#include <linux/wait.h>
#include <linux/poll.h>
#include <linux/fs.h>
#include <linux/fcntl.h>
#include <linux/platform_device.h>
#include <asm/mach/map.h>
#include <asm/uaccess.h>
#include <asm/io.h>

#define PA_CFG1_ADDR    (0x01c20804)
#define PA_DATA_ADDR    (0x01c20810)
#define REGISTER_LENGTH	4

static void led_release(struct device *dev)
{
    printk("led device released!\r\n");
}

static struct resource led_resources[] = {
    [0] =   {
        .start  =   PA_CFG1_ADDR,
        .end    =   (PA_CFG1_ADDR + REGISTER_LENGTH - 1),
        .flags  =   IORESOURCE_MEM,
    },
    [1] =   {
        .start  =   PA_DATA_ADDR,
        .end    =   (PA_DATA_ADDR + REGISTER_LENGTH - 1),
        .flags  =   IORESOURCE_MEM,
    },
};

/*
 * platform设备结构体 
 */
static struct platform_device leddevice = {
	.name = "Ori_led",
	.id = -1,
	.dev = {
		.release = &led_release,
	},
	.num_resources = ARRAY_SIZE(led_resources),
	.resource = led_resources,
};

/*
 * @description	: 设备模块加载 
 * @param 		: 无
 * @return 		: 无
 */
static int __init leddevice_init(void)
{
	return platform_device_register(&leddevice);
}

/*
 * @description	: 设备模块注销
 * @param 		: 无
 * @return 		: 无
 */
static void __exit leddevice_exit(void)
{
	platform_device_unregister(&leddevice);
}

module_init(leddevice_init);
module_exit(leddevice_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("HRX");
